#pragma once

template<typename SubClass>
class SingletonT
{
	friend typename SubClass;
public:
	static SubClass* Get()
	{
		if(!m_ins)
			new SubClass();
		return m_ins;
	}
	static void Release()
	{
		delete m_ins;
		m_ins = NULL;
	}

private:
	static SubClass* m_ins;
	SingletonT()
	{
		assert(!m_ins);
		m_ins = static_cast<SubClass*>(this);
	}
	virtual ~SingletonT()
	{
	}
};

template<typename T> T* SingletonT<T>::m_ins = NULL;

